<%@page import="com.seniorproject.aims.PasswordHandler"%>
<%@page trimDirectiveWhitespaces="true"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import = "java.util.List" %>
<%@ page import ="java.util.ArrayList"%>
<%@ page import ="javax.script.Invocable"%>
<%@ page import ="javax.script.ScriptEngine"%>
<%@ page import ="javax.script.ScriptEngineManager"%>
<%@ page import ="java.io.BufferedReader"%>
<%@ page import ="java.io.File"%>
<%@ page import ="java.io.FileInputStream"%>
<%@ page import = "com.seniorproject.aims.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/stylev2.css" />
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/blue_button.css" />
 <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootbox.js"></script>
<style>


</style>
<script>

$(document).ready(function(){
	
	  var xmlhttp;
//	  var temp = document.getElementById("file_path_message");
//	  var file_path = temp.innerHTML();
		var file_path ;
		var student_id ;
		file_path = document.getElementById("file_path_message").value;
		student_id = document.getElementById("student_id").value;
		if(window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp = new XMLHttpRequest();
		}
		else {
			// code for IE6, IE5
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {	
				//alert("I'm Back");//////////////////
				
				var result = xmlhttp.responseText;
				alert("result:"+result);
				if(result=="fail")
				{
					alert("ไม่สามารถทำการ Import ไฟล์ดังกล่าวได้ กรุณาตรวจสอบรูปแบบไฟล์นำเข้า");
				}
				else {
					
					
					document.getElementById("progress_bar").style.width="100%";
					var x =  document.getElementById("progress_bar") ; 
						x.innerHTML ="100%";
				}
				
				
			
			}// end if check state
		}// end function
		
		//alert("Before send :" + file_path);
		xmlhttp.open("POST", "enrollold_import_excel_background.jsp?file_path="+file_path+"&student_id="+student_id, true);
		xmlhttp.send();

	
	
});


</script>

</head>
<body>

<%

	//get session
		String strUser = String.valueOf(session.getAttribute("sUser"));
		HttpSession htp_session = request.getSession();
		
		// check session
		if (htp_session == null || htp_session.getAttribute("sUser") == null) {
		    // Forward the control to login.jsp if authentication fails or session expires
		    request.getRequestDispatcher("/login.jsp").forward(request,
		        response);
		}
		if("admin".equals(htp_session.getAttribute("sUser"))){%>
			<script>alert("This user dont have PERMISSION to access this zone.");</script>
			<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=system_select.jsp"> 	
	<%}
		
	
	

%>

<div id="page-wrap">
		<div id="inside">
			<table border="0">
				<tr style="font-size:24px">
					<td width="600" height="100" style= "background-color: #273b80;border: 0px ;padding: 0px; 0px;" >
						<div id="header_banner-2"></div>
					</td>
					
					<td width="680" height="100" style= "background-color: #273b80;border: 0px;padding: 0px; 0px;" >
						<p align="right"><label><font size="4" color="#ffffff">username : <%=strUser%>&nbsp;&nbsp;</font></label></p>
						<a href="logout.jsp"><p align="right"><label><font size="3" color="#ffffff">log out</font></label></p></a>
					</td>
				</tr>
			</table>

				
				<div id="main-content-ac">
					
					<div class="container">
					<center>
  						<h2>Import In Progress</h2>
  					</center>	
					 <div class="progress">
					    <div id="progress_bar" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%">
					      50%
					    </div>
					  </div>
					</div>
					
					  <input type="hidden" id = "file_path_message" value="<%= request.getAttribute("message") %>">
					  <input type="hidden" id = "student_id" value="<%= request.getAttribute("student_id") %>">
					  <br><br><br><br><br><br><br>
					  <center>
					  			<a href="enroll_enrollment.jsp" class="myButton">ย้อนกลับ</a>
					  </center>
					  
					  <br><br><br>
					
					
				</div>	
				
			<div style="clear: both;"></div>
			
			
				
			<div id="footer"></div>
			
		</div>		
			<div style="clear: both;"></div>		
   </div>


</body>
</html>